﻿
namespace Com.Christoc.HomeController.Controls
{
    using System;
    using Components;
    using System.Web.UI.WebControls;

    public partial class Default : HomeControllerModuleBase
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        
        protected void DeviceListGridView_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            //figure out which row was selected, and get the device address (tablecell)
            var index = Convert.ToInt32(e.CommandArgument);
            GridViewRow grv = DeviceListGridView.Rows[index];
            var deviceAddress = grv.Cells[2];

            if(e.CommandName=="On")
            {
                Communication.DeviceOn(deviceAddress.Text);
            }
            if (e.CommandName == "Off")
            {
                Communication.DeviceOff(deviceAddress.Text);
            }
        }
    }
}